﻿//_______________________________________________________________________________________________________________________
// Copy Right (c) 2010, 2011 SapiensIT Consulting GmbH, all rights reserved
//_______________________________________________________________________________________________________________________
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT
// NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//_______________________________________________________________________________________________________________________
// PROJECT:     sapiens.at.SharePoint (SharePoint 2010/V4)
//_______________________________________________________________________________________________________________________
// VERSION:     2.0
//_______________________________________________________________________________________________________________________
// DESCRIPTION: 
//_______________________________________________________________________________________________________________________
// LICENSE:     Different licens Types apply to different file types:
//               - Source code files are governed by the MICROSOFT PUBLIC LICENSE (Ms-PL)
//               - Binary files are governed by MSDN CODE GALLERY BINARY LICENSE
//               - Documentation files are governed by CREATIVE COMMONS ATTRIBUTION 3.0 LICENSE
//
//               The licenses can be found at the projects source location.
//               If you do not agree, don't use it!
// 
//_______________________________________________________________________________________________________________________
// Start SharePoint Branding, visit http://www.cliggin.com! Visit us on http://www.sapiens.at! Tell your friends! 
//_______________________________________________________________________________________________________________________
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sapiens.at.SharePoint.Mail.ICalendar
{
    /// <summary>
    /// Represents an Event in an ICalendar Meeting Request
    /// </summary>
    public class Event : CalendarComponent
    {
        /// <summary>
        /// Instantiates the event
        /// </summary>
        public Event()
            : base()
        {
            Organizer = new Organizer();
            Status = "CONFIRMED";
        }
        /// <summary>
        /// Instantiates the event
        /// </summary>
        /// <param name="eventStart">EventDate</param>
        /// <param name="eventEnd">EndDate</param>
        /// <param name="uID">Unique ID/GUID of the event listitem</param>
        /// <param name="organizer">Organizer - eventsList</param>
        /// <param name="attendees">Attendees</param>
        /// <param name="description">Description</param>
        /// <param name="summary">Summary</param>
        /// <param name="location">Location</param>
        public Event(DateTime eventStart, DateTime eventEnd, string uID, Organizer organizer, List<Attendee> attendees, string description, string summary, string location)
            : base()
        {
            DTStamp = DateTime.Now;
            EventStart = eventStart;
            EventEnd = eventEnd;
            UID = uID;
            Organizer = organizer;
            Attendees = attendees;
            Description = description;
            Subject = summary;
            Location = location;
            Status = "CONFIRMED";
        }
        #region Properties
        /// <summary>
        /// Attendees
        /// </summary>
        [CalendarKeyWordAttribute("ATTENDEE")]
        public List<Attendee> Attendees { get; set; }

        private string _uid = string.Empty;
        /// <summary>
        /// Unique ID
        /// </summary>
        [CalendarKeyWordAttribute("UID")]
        public string UID
        {
            get { return _uid; }
            set
            {
                _uid = value;
                // if (_uid.Length > 36) _uid = _uid.Substring(0, 36);
            }
        }
        /// <summary>
        /// Organizer
        /// </summary>
        [CalendarKeyWordAttribute("ORGANIZER")]
        public Organizer Organizer { get; set; }
        /// <summary>
        /// Description/ E-Mail Body
        /// </summary>
        [CalendarKeyWordAttribute("DESCRIPTION")]
        public string Description { get; set; }
        /// <summary>
        /// specifies non-processing information intended to provide a comment to the calendar user
        /// </summary>
        [CalendarKeyWordAttribute("COMMENT")]
        public string Comment { get; set; }
        /// <summary>
        /// E-Mail Subject
        /// </summary>
        [CalendarKeyWordAttribute("SUMMARY")]
        public string Subject { get; set; }
        /// <summary>
        /// Event Start
        /// </summary>
        [CalendarKeyWordAttribute("DTSTART")]
        public DateTime EventStart { get; set; }
        /// <summary>
        /// EventEnd
        /// </summary>
        [CalendarKeyWordAttribute("DTEND")]
        public DateTime EventEnd { get; set; }
        /// <summary>
        /// Location
        /// </summary>
        [CalendarKeyWordAttribute("LOCATION")]
        public string Location { get; set; }
        /// <summary>
        /// Status
        /// </summary>
        [CalendarKeyWordAttribute("STATUS")]
        public string Status { get; set; }
        /// <summary>
        /// TimeStamp
        /// </summary>
        [CalendarKeyWordAttribute("DTSTAMP")]
        public DateTime DTStamp { get; set; }
        private string _sequence = "0";
        /// <summary>
        ///  defines the revision sequence number of the calendar component within a sequence of revisions
        ///  Default: 0
        /// </summary>
        [CalendarKeyWordAttribute("SEQUENCE")]
        public string Sequence
        {
            get { return _sequence; }
            set { _sequence = value; }
        }
        private string _priority = "0";
        /// <summary>
        /// The property defines the relative priority for a calendar component
        /// Values: 0...No Priority, 1...Highest Priority, 2, 3, ...
        /// Default: 0
        /// </summary>
        [CalendarKeyWordAttribute("PRIORITY")]
        public string Priority
        {
            get
            {
                return _priority;
            }
            set
            {
                _priority = value;
            }
        }
        /// <summary>
        /// defines the access classification for a calendar component
        /// Values: PUBLIC, PRIVATE, CONFIDENTIAL
        /// </summary>
        [CalendarKeyWordAttribute("CLASS")]
        public string Class { get; set; }
        /// <summary>
        /// When was the Calendar Information created
        /// </summary>
        [CalendarKeyWordAttribute("CREATED")]
        public string Created { get; set; }
        /// <summary>
        /// When was the Calendar Information last modified
        /// </summary>
        [CalendarKeyWordAttribute("LAST-MODIFIED")]
        public string LastModified { get; set; }
        private string _transp = "OPAQUE";
        /// <summary>
        /// defines whether an event is transparent or not to busy time searches
        /// Values: OPAQUE, TRANSPARENT
        /// Default: OPAQUE
        /// </summary>
        [CalendarKeyWordAttribute("TRANSP")]
        public string Transp
        {
            get { return _transp; }
            set { _transp = value; }
        }
        /// <summary>
        /// Provide a grouping of component properties that define an alarm.
        /// </summary>
        [CalendarKeyWordAttribute("BEGIN:VALARM")]
        public string BeginAlarm { get; set; }
        /// <summary>
        /// specifies when an alarm will trigger
        /// </summary>
        [CalendarKeyWordAttribute("TRIGGER")]
        public string Trigger { get; set; }
        /// <summary>
        /// Defines the end of the alarm grouping
        /// </summary>
        [CalendarKeyWordAttribute("END:VALARM")]
        public string EndAlarm { get; set; }
        /// <summary>
        /// Defines the end of the alarm component
        /// </summary>
        [CalendarKeyWordAttribute("END:VEVENT")]
        public string EndVEvent { get; set; }
        private TimeSpan _alarmBeforeEventStarts = new TimeSpan(1, 0, 0);
        /// <summary>
        /// Defines the timespan, when the alarm will trigger
        /// Default: 1 hour
        /// </summary>
        public TimeSpan AlarmBeforeEventStarts { get; set; }

        [CalendarKeyWordAttribute("X-MICROSOFT-CDO-APPT-SEQUENCE:")]
        public string XSequence { get; set; }
        [CalendarKeyWordAttribute("X-MICROSOFT-CDO-OWNERAPPTID:")]
        public string XOwnerAppID { get; set; }
        [CalendarKeyWordAttribute("X-MICROSOFT-CDO-BUSYSTATUS:")]
        public string XBusyStatus { get; set; }
        [CalendarKeyWordAttribute("X-MICROSOFT-CDO-INTENDEDSTATUS:")]
        public string XIntendedStatus { get; set; }
        [CalendarKeyWordAttribute("X-MICROSOFT-CDO-ALLDAYEVENT:")]
        public string XAllDayEvent { get; set; }
        [CalendarKeyWordAttribute("X-MICROSOFT-CDO-IMPORTANCE:")]
        public string XImportance { get; set; }
        [CalendarKeyWordAttribute("X-MICROSOFT-CDO-INSTTYPE:")]
        public string XInstType { get; set; }
        #endregion
    }
}
